package com.jbit.dm212.controller;

import com.alipay.api.AlipayApiException;
import com.jbit.dm212.common.DmAlipayUtil;
import com.jbit.dm212.common.ResponseResult;
import com.jbit.dm212.common.ResponseResultUtils;
import com.jbit.dm212.entity.alipay.AliOrderReturn;
import com.jbit.dm212.entity.po.DmOrder;
import com.jbit.dm212.service.DmOrderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.util.Calendar;

@RestController
@RequestMapping("/pay/api/p")
public class AlipayPublicController {
    @Resource
    private DmOrderService orderService;
    @GetMapping("/tradesuccess")
    public ResponseResult tradeSuccess(AliOrderReturn orderReturn){
        DmOrder order = new DmOrder();
        order.setOrderNo(orderReturn.getOut_trade_no());
        order.setAliTradeNo(orderReturn.getTrade_no());
        order.setOrderType(2);
        order.setUpdatedTime(Calendar.getInstance().getTime());
        orderService.updateOrderType(order);
        return ResponseResultUtils.sendSuccess();
    }

}
